/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */

// The editor creator to use.
import DecoupledeEditorBase from '@ckeditor/ckeditor5-editor-decoupled/src/decouplededitor';

import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials';
import UploadAdapter from '@ckeditor/ckeditor5-adapter-ckfinder/src/uploadadapter';
import Autoformat from '@ckeditor/ckeditor5-autoformat/src/autoformat';
import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold';
import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic';
import BlockQuote from '@ckeditor/ckeditor5-block-quote/src/blockquote';
import CKFinder from '@ckeditor/ckeditor5-ckfinder/src/ckfinder';
import EasyImage from '@ckeditor/ckeditor5-easy-image/src/easyimage';
import Heading from '@ckeditor/ckeditor5-heading/src/heading';
import Image from '@ckeditor/ckeditor5-image/src/image';
import ImageCaption from '@ckeditor/ckeditor5-image/src/imagecaption';
import ImageStyle from '@ckeditor/ckeditor5-image/src/imagestyle';
import ImageToolbar from '@ckeditor/ckeditor5-image/src/imagetoolbar';
import ImageUpload from '@ckeditor/ckeditor5-image/src/imageupload';
import Link from '@ckeditor/ckeditor5-link/src/link';
import List from '@ckeditor/ckeditor5-list/src/list';
import MediaEmbed from '@ckeditor/ckeditor5-media-embed/src/mediaembed';
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
import PasteFromOffice from '@ckeditor/ckeditor5-paste-from-office/src/pastefromoffice';
import Table from '@ckeditor/ckeditor5-table/src/table';
import TableToolbar from '@ckeditor/ckeditor5-table/src/tabletoolbar';

import Alignment from '@ckeditor/ckeditor5-alignment/src/alignment';     // <--- ADDED
import Underline from '@ckeditor/ckeditor5-basic-styles/src/underline';
import Strikethrough from '@ckeditor/ckeditor5-basic-styles/src/strikethrough';
import Code from '@ckeditor/ckeditor5-basic-styles/src/code';
import Highlight from '@ckeditor/ckeditor5-highlight/src/highlight';

import FontFamily from '@ckeditor/ckeditor5-font/src/fontfamily';  //添加
import FontSize from '@ckeditor/ckeditor5-font/src/fontsize';  //添加
import FontColor from '@ckeditor/ckeditor5-font/src/fontcolor';  //添加
import FontBackgroundColor from '@ckeditor/ckeditor5-font/src/fontbackgroundcolor';  //添加

import SubScript from '@ckeditor/ckeditor5-basic-styles/src/subscript';  //上标
import SuperScript from '@ckeditor/ckeditor5-basic-styles/src/superscript';  //下标



export default class DecoupledeEditor extends DecoupledeEditorBase {}

// Plugins to include in the build.
DecoupledeEditor.builtinPlugins = [
	Essentials,
	UploadAdapter,
	Autoformat,
	Bold,
	Italic,
	BlockQuote,
	CKFinder,
	EasyImage,
	Heading,
	Image,
	ImageCaption,
	ImageStyle,
	ImageToolbar,
	ImageUpload,
	Link,
	List,
	MediaEmbed,
	Paragraph,
	PasteFromOffice,
	Table,
	TableToolbar,
	Alignment,
	FontFamily,
	FontSize,
	FontColor,
	FontBackgroundColor,
	Underline,
	Strikethrough,
	Code,
	Highlight,
	SubScript,
	SuperScript
];

// Editor configuration.
DecoupledeEditor.defaultConfig = {
	toolbar: {
		items: [
			'heading','|',
			'undo','redo','|',
			'alignment:left', 'alignment:right', 'alignment:center', 'alignment:justify','|',
			'fontFamily','fontSize','fontColor','fontBackgroundColor','|',
			'bold','italic','subscript','superscript','underline','strikethrough','highlight','|',
			'bulletedList','numberedList','|',
			'imageUpload','mediaEmbed','link','blockQuote','insertTable',
		]
	},
	placeholder: '请输入提案正文...',
	ckfinder: {
		openerMethod:'popup',
		options:{
			resourceType: 'Images',
			height : '500px',
			width : '50%'
		},
		uploadUrl : '/upload/img-temp'
	},
	//后端处理上传逻辑返回json数据,包括uploaded(选项true/false)和url两个字段 }
	image: {
		toolbar: [
			'imageStyle:alignCenter',
			'imageStyle:alignLeft',
			'imageStyle:alignRight',
			'imageStyle:full',
			'imageStyle:side'
		],
		styles: ['full','side','alignLeft','alignCenter','alignRight']
	},
	table: {
		contentToolbar: [
			'tableColumn',
			'tableRow',
			'mergeTableCells'
		]
	},
	language: 'en'
};
